﻿@using ZX.Model
@using ZX.Tools
@model Document_Manager
@{
    ViewBag.Title = "文档查看-指效OA";
}
<link href="~/Static/styles/bootstrap.min.css" rel="stylesheet" />
<link href="~/Static/styles/theme/default/style.css" rel="stylesheet" />
<link href="~/Static/js/jquery/chosen/chosen.min.css" rel="stylesheet" />
<link href="~/Static/js/jquery/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
<link href="~/Static/js/layer/need/layer.css" rel="stylesheet" />
<link href="~/Static/js/layui/css/layui.css" rel="stylesheet" />
<link href="~/Static/js/zui/css/zui.min.css" rel="stylesheet" />
<script src="~/Static/js/jquery/jquery-1.11.1.min.js"></script>
<script src="~/Static/js/Validform/js/Validform_v5.3.2_min.js"></script>
<script src="~/Static/js/jquery/form/min.js"></script>
<script src="~/Static/js/jquery/chosen/chosen.min.js"></script>
<script src="~/Static/js/jquery/zTree/js/jquery.ztree.core-3.1.min.js"></script>
<script src="~/Static/js/jquery/zTree/js/jquery.ztree.excheck-3.1.min.js"></script>
<script src="~/Static/js/jquery/zTree/js/jquery.ztree.all-3.1.min.js"></script>
<script charset="utf-8" src="~/Static/js/ueditor/ueditor.config.js"></script>
<script charset="utf-8" src="~/Static/js/ueditor/ueditor.all.min.js"></script>
<script charset="utf-8" src="~/Static/js/ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="~/Static/js/zui/zui.min.js"></script>
<script src="~/Static/js/framework.js"></script>
<script src="~/Static/js/layui/layui.js"></script>
<script src="~/Static/js/layer/layer.js"></script>
<script src="~/Static/js/layer/layer.tools.js"></script>
<style>
    .top-navbar-index {
        position: inherit;
        width: 100%;
        margin-bottom: 0;
    }

    .row {
        margin: 0;
        padding: 20px;
    }
</style>
<script language='javascript'>
    $("body").children("div[class='container']").attr("class", "m-company-setbasic");
</script>
<div id="sysDTypeTree" class="menuContent" style="display: none; position: absolute;">
    <ul id="treeDocType" class="ztree" style="margin-top: 0;"></ul>
</div>

<input type="hidden" id="txtDTypeTree" value="@ViewBag.TreeJson" />
<input type="hidden" id="currentMid" value="@ViewBag.CurrentMid">
<input type="hidden" id="isPrivate" value="@ViewBag.IsPrivate">
<input type="hidden" id="secondMenuId" name="secondMenuId" value="@ViewBag.SecondMenuId" />

@Html.Raw(ViewBag.SysAdminMainNavbar)
<div class='row page-content'>
    <nav id='menu'>
        <ul class='nav'>
            <li>
                <a href='javascript:;'>@Model.DTitle</a>
            </li>
            <li class='divider angle'></li>
        </ul>
    </nav>
    <div class='panel with-menu page-content' style="float:left">
        <div class='panel-heading'>
            <strong><small class='text-muted'><i class='icon icon-plus'></i></small> 查看文档</strong>
        </div>
        <div class='panel-body'>
            <form class="form-horizontal" method='post' id='ajaxForm' action="SaveData">
                <input type="hidden" id="FK_TypeId" name="FK_TypeId" value="@ViewBag.FK_TypeId">
                <input type="hidden" id="Id" name="Id" value="@Model.Id">
                <div class="form-group">
                    <label for="FK_TypeId" class="col-sm-2">
                        所属分类
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <div class="input-group">
                            <input type='text' placeholder='类目' id='txtDTypeParent' value='@(ViewBag.DTypeName ?? "顶级")' class='form-control' readonly='readonly' onclick='showSysDocTypeTree()' />
                            <label class="input-group-addon">
                                @{
                                    if (ViewBag.IsPrivate == 1)
                                    {
                                        <input type="checkbox" name="IsPrivate" disabled value="@ViewBag.IsPrivate" id="IsPrivate" checked>
                                    }
                                    else
                                    {
                                        <input type="checkbox" name="IsPrivate" disabled value="@ViewBag.IsPrivate" id="IsPrivate">
                                    }
                                }

                            </label>
                            <span class="input-group-addon">设为私密</span>
                        </div>
                    </div>
                </div>
                <div id="div_AuthUser" class="form-group">
                    <label for="AuthUserId" class="col-sm-2">
                        授权用户
                    </label>
                    <input type="hidden" id="AuthUserId" name="AuthUserId" class="form-control" value="@Model.AuthUserId" placeholder="授权用户">
                    <div class="col-md-10 col-sm-10">
                        <select data-placeholder="选择用户..." class="chosen-select form-control" tabindex="2" multiple="">
                            @{
                                if (ViewBag.AuthUserList != null)
                                {
                                    foreach (var item in ViewBag.AuthUserList as IEnumerable<SelectListItem>)
                                    {
                                        bool bl = true;
                                        if (Model.AuthUserId.IsNotNullOrEmpty())
                                        {
                                            List<string> AuthUserList = Model.AuthUserId.Split(',').ToList();

                                            if (AuthUserList.Contains(item.Value))
                                            {
                                                <option value="@item.Value" data-keys="@item.Value" selected>@item.Text</option>
                                                bl = false;
                                                continue;
                                            }
                                        }

                                        if (bl)
                                        {
                                            <option value="@item.Value" data-keys="@item.Value"> @item.Text </option>
                                        }
                                    }
                                }
                            }
                        </select>
                    </div>
                </div>
                <div class="form-group" id="div_AuthRole">
                    <input type="hidden" id="AuthRole" name="AuthRole" value="@Model.AuthRole" placeholder="授权角色" class="form-control">
                    <label for="RoleList" class="col-sm-2">
                        授权分组
                    </label>
                    <div class="col-md-10 col-sm-10">
                        @{
                            List<Sys_Role> list = ViewBag.RoleListList;
                            if (list != null)
                            {
                                foreach (var item in list)
                                {
                                    bool bl = true;
                                    if (!Model.AuthRole.IsNullOrEmpty())
                                    {
                                        List<string> authRole = Model.AuthRole.Split(',').ToList();
                                        if (authRole.Contains(item.Id.ToString()))
                                        {
                                            <label class="checkbox-inline">
                                                <input type="checkbox" name="visitorsList" value="@item.Id" checked> @item.RName
                                            </label>
                                            bl = false;
                                            continue;
                                        }
                                    }
                                    if (bl)
                                    {
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="visitorsList" value="@item.Id"> @item.RName
                                        </label>
                                    }

                                }
                            }
                        }
                    </div>
                </div>
                <div class="form-group">
                    <input type="hidden" id="DType" name="DType" value="@Model.DType" placeholder="文档类型" class="form-control">
                    <label for="DType" class="col-sm-2">
                        文档类型
                    </label>
                    <div class="col-md-10 col-sm-10">
                        @{
                            switch (Model.DType)
                            {
                                case 0:
                                    {
                                        <label class='radio-inline'>
                                            <input type='radio' name='type' value='text' checked='checked' onclick=setType(this.value) id='typetext' />文档
                                            <input type='radio' name='type' value='url' onclick=setType(this.value) id='typeurl' />链接
                                        </label>
                                        break;
                                    }
                                case 10:
                                    {
                                        <label class='radio-inline'>
                                            <input type='radio' name='type' value='text' onclick=setType(this.value) id='typetext' />文档
                                            <input type='radio' name='type' value='url' checked='checked' onclick=setType(this.value) id='typeurl' />链接
                                        </label>
                                        break;
                                    }
                            }

                        }
                    </div>
                </div>
                <div class="form-group">
                    <label for="DTitle" class="col-sm-2">
                        文档标题
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <input type="text" id="DTitle" name="DTitle" value="@Model.DTitle" placeholder="标题" class="form-control">
                    </div>
                </div>
                <div class="form-group" id="div_DUrl">
                    <label for="DUrl" class="col-sm-2">
                        文档URL
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <input type="text" id="DUrl" name="DUrl" value="@Model.DUrl" placeholder="URL" class="form-control">
                    </div>
                </div>
                <div class="form-group" id="div_DContent">
                    <label for="DContent" class="col-sm-2">
                        文档正文
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <textarea id="DContent" name="DContent" rows='7'>@Model.DContent</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="DKey" class="col-sm-2">
                        关键字
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <input type="text" id="DKey" name="DKey" value="@Model.DKey" placeholder="关键字" class="form-control">
                    </div>
                </div>
                <div class="form-group">
                    <label for="DAbs" class="col-sm-2">
                        文档摘要
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <textarea name='DAbs' id='DAbs' class='form-control' rows=3>@Model.DAbs</textarea>
                    </div>
                </div>
                <div id="div_Attach" class="form-group">
                    <label for="Attach" class="col-sm-2">
                        附件
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <input type="hidden" name="Attach" id="Attach" value="@Model.Attach" />
                        <label id="lblAttach">@Model.Attach</label>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <a href='javascript:history.go(-1);' class='btn btn-back '>返回</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src='~/res/js/jquery/form/min.js?v=4.6.2' type='text/javascript'></script>
<script language='javascript'>
    var edtor = initUEditor('DContent');

    var menuSetting = {
        view: {
            dblClickExpand: false
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            onClick: onDocTypeClick
        }
    }; //初始化树形分类

    var menuNodes = eval($("#txtDTypeTree").val());
    menuTree = $.fn.zTree.init($("#treeDocType"), menuSetting, menuNodes);

    $('select.chosen-select').chosen({
        no_results_text: '没有找到',    // 当检索时没有找到匹配项时显示的提示文本
        disable_search_threshold: 10, // 10 个以下的选择项则不显示检索框
        search_contains: true         // 从任意位置开始检索
    });

    $('select.chosen-select').on('change', function () {
        // 用户改变了选择
        $("#AuthUserId").val($(this).val());
    });

    //点击选择分类
    function onDocTypeClick(e, treeId, treeNode) {
        $("#FK_TypeId").val(treeNode.id);
        $("#txtDTypeParent").val(treeNode.name);
        hideDocType();
    }
    //显示分类
    function showSysDocTypeTree() {
        var cityObj = $("#txtDTypeParent");
        var cityOffset = $("#txtDTypeParent").offset();
        $("#treeDocType").width(cityObj.width());
        $("#sysDTypeTree").css({ left: cityOffset.left + "px", top: cityOffset.top + cityObj.outerHeight() + "px" }).slideDown("fast");
        $("#sysDTypeTree").css("z-index", "10")
        $("body").bind("mousedown", onAddDocTypeBodyDown);
    }
    //隐藏分类
    function hideDocType() {
        $("#sysDTypeTree").fadeOut("fast");
        $("body").unbind("mousedown", onAddDocTypeBodyDown);
    }
    //隐藏分类
    function onAddDocTypeBodyDown(event) {
        if (!(event.target.id == "menuBtn" || event.target.id == "sysDTypeTree" || $(event.target).parents("#sysDTypeTree").length > 0)) {
            hideDocType();
        }
    }

</script>
